package com.fr.base.background;

import com.fr.base.core.GraphHelper;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;

public class IntervalColorBackground extends AbstractBackground
{
  private static final long serialVersionUID = -3686146578900215327L;
  private Color bgColor;
  private int position = 2;
  private double intervalLength;

  public IntervalColorBackground()
  {
  }

  public IntervalColorBackground(Color paramColor, int paramInt)
  {
    this.bgColor = paramColor;
    this.position = paramInt;
  }

  public void paint(Graphics paramGraphics, Shape paramShape)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Paint localPaint = localGraphics2D.getPaint();
    double d1 = getIntervalLength();
    if (paramShape instanceof Rectangle2D)
    {
      int k;
      Rectangle2D localRectangle2D = (Rectangle2D)paramShape;
      double d2 = localRectangle2D.getWidth();
      double d3 = localRectangle2D.getHeight();
      double d4 = localRectangle2D.getX();
      double d5 = localRectangle2D.getY() + d3;
      int i = (int)(d3 / d1);
      int j = (int)(d2 / d1);
      if ((getPosition() == 2) || (getPosition() == 4))
      {
        for (k = 0; k < i; ++k)
          if (k % 2 == 0)
          {
            localGraphics2D.setPaint(this.bgColor);
            GraphHelper.fillRect(localGraphics2D, d4, d5 - (k + 1) * d1, d2, d1);
          }
        if (i % 2 == 0)
          localGraphics2D.setPaint(this.bgColor);
        else
          localGraphics2D.setPaint(null);
        GraphHelper.fillRect(localGraphics2D, d4, localRectangle2D.getY(), d2, d3 - i * d1);
      }
      else
      {
        for (k = 0; k < j; ++k)
          if (k % 2 == 0)
          {
            localGraphics2D.setPaint(this.bgColor);
            GraphHelper.fillRect(localGraphics2D, d4 + k * d1, localRectangle2D.getY(), d1, d3);
          }
        if (j % 2 == 0)
          localGraphics2D.setPaint(this.bgColor);
        else
          localGraphics2D.setPaint(null);
        GraphHelper.fillRect(localGraphics2D, d4 + j * d1, localRectangle2D.getY(), d2 - j * d1, d3);
      }
    }
    localGraphics2D.setPaint(localPaint);
  }

  public void setColor(Color paramColor)
  {
    this.bgColor = paramColor;
  }

  public Color getColor()
  {
    return this.bgColor;
  }

  public void setPosition(int paramInt)
  {
    this.position = paramInt;
  }

  public int getPosition()
  {
    return this.position;
  }

  public void setIntervalLength(double paramDouble)
  {
    this.intervalLength = paramDouble;
  }

  public double getIntervalLength()
  {
    return this.intervalLength;
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    return null;
  }

  public String getBackgroundType()
  {
    return null;
  }
}